#ifndef IDENTITY_H
#define IDENTITY_H

#include"automaton.h"

class IdentityState{
	public:
	static const unsigned int INIT = 0;
	static const unsigned int PREFIX = 1;
	static const unsigned int SUFFIX = 2; 

};

class IdentityInputTable{
	public:
	static const int LETTER = 0;
	static const int NUMBER = 1;

	static int Translate(unsigned char input){
		if((input >= 'a' && input <= 'z') || (input >= 'A' && input <= 'Z') || (input == '_')){
			return IdentityInputTable::LETTER;
		}
		else if(input >= '0' && input <= '9'){
			return IdentityInputTable::NUMBER;
		}
		else{
			return -1;
		}
	}
};

class Identity:public Automaton{
	public:
	Identity():Automaton(3,2){
		
		Translate(IdentityState::INIT,IdentityInputTable::LETTER,IdentityState::PREFIX);
		Translate(IdentityState::PREFIX,IdentityInputTable::LETTER,IdentityState::SUFFIX);
		Translate(IdentityState::PREFIX,IdentityInputTable::NUMBER,IdentityState::SUFFIX);
		Translate(IdentityState::SUFFIX,IdentityInputTable::LETTER,IdentityState::SUFFIX);
		Translate(IdentityState::SUFFIX,IdentityInputTable::NUMBER,IdentityState::SUFFIX);

		AddAcceptState(IdentityState::PREFIX);
		AddAcceptState(IdentityState::SUFFIX);
	}
	virtual unsigned int TranslateInput(unsigned char ch){
		return IdentityInputTable::Translate(ch);	
	}
};
#endif
